
************************************************************************
** code industry variable into 3 categories depending on skill level  **
************************************************************************
recode industry1 65=66 // both have the label "Services / Office" 

cap drop industry1_temp industry2_temp industry1_num* industry2_num* industry1_max industry2_max

* if missing sector code, but other employees only have 1 sector code, replace with that code

forvalues i=1/2 {
tab industry`i'
g industry`i'_temp=industry`i'
if `i'==1 replace industry`i'_temp=. if inlist(industry`i',-1,-2,93,94) 
else replace industry`i'_temp=. if inlist(industry`i',-1,-2) 
bys bur_id (industry`i'_temp): g industry`i'_num_=sum(industry`i'_temp!=industry`i'_temp[_n-1]) if !mi(industry`i'_temp)
bys bur_id: egen industry`i'_num=max(industry`i'_num_)
bys bur_id: egen industry`i'_max=max(industry`i'_temp)
replace industry`i'_temp=industry`i'_max if mi(industry`i'_temp) & industry`i'_num==1
replace industry`i'_temp=industry`i' if mi(industry`i'_temp)
ren industry`i' industry`i'_orig
ren industry`i'_temp industry`i'
tab year if industry`i'!=industry`i'_orig
drop industry`i'_max  industry`i'_num* industry`i'_orig
tab industry`i'
}


****************
** industry2 ***
****************

cap drop high2 low2 med2 

g high2 = (inlist(industry2, ///
93, /// /* Embassies and international representations */
92, /// /* State insurance */
91, /// /* Authorities and administration */
83, /// /* Medicine and healthcare */
82, /// /* Research and Development */
81, /// /* Education */
75, /// /* Commercial services */
73, /// /* Real estate brokerage and administration */
72, /// /* Insurance */
71, /// /* Banking industry */
66, /// /* Message transfer */
36  /// /* Precision mechanics */
) & emp==1)



g med2 = (inlist(industry2, ///
88, /// /* Leisure and entertainment*/
87, /// /* Associations, associations and parties */
86, /// /* Religious and ideological associations */
74, /// /* Rental of equipment and vehicles */
64, /// /* Aviation */
58, /// /*"Repairs"*/
56, /// /* Retail trade */
55, /// /* Retail trade in general*/
51, /// /* Wholesale trade of finished goods */
54, /// /* Intermediary general */
42, /// /* Installations on construction */
37, /// /* Watchindurstrie */
25, /// /* Clothing*/
22, /// /*"Drinks"*/
21 /// /*"Food"*/
) & emp==1)



g low2 = (inlist(industry2, ///
89, /// /*"Domestic services" */
85, /// /*"Dormitories and welfare care" */
84, /// /*"Waste disposal and recycling" */
76, /// /* Personal services */
65, /// /*"Transportation" */
63, /// /*"Shipping" */
62, /// /*"Road traffic and pipelines" */
61, /// /*"Lanes" */
57, /// /*"Catering" */
53, /// /*"Wholesale general" */
52, /// /*"Wholesale trade" */
41, /// /*"Construction industry" */
38, /// /*"Other processing of materials" */
35, /// /*"Machinery and vehicle construction" */
34, /// /*"Metal processing" */
33, /// /*"Glass, stones and earth" */
32, /// /*"Plastics" */
31, /// /*"Chemicals" */
29, /// /* Leather products  */
28, /// /* Publishing and printing */
27, /// /*"Paper manufacture" */
26, /// /*"Wood processing" */
24, /// /*"Textile industry" */
23, /// /*"Smoking articles" */
12, /// /*"Mining" */
11, /// /* Energy-and water supply*/
4,  /// /*"Fishing" */
3,  /// /*"Forestry" */
2,  /// /*"Horticulture" */
1   /// /*"Agriculture" */
) & emp==1)

  
/*  
 -1 "Unknown"
 -2 "Without specification"
*/

***************
** industry1 **
***************

cap drop high1 low1 med1 

g high1 = (inlist(industry1, ///
90, /// /*"Education" */
85, /// /*"Science" */
83, /// /*"Health" */
81, /// /*"Legal services" */
66, /// /*"Services / Office" */
64, /// /*"Entrepreneurs, senior civil servants" */
62, /// /*"Technical specialists and auxiliary professions" */
60 /// /*"Architecture and engineering" */
) & emp==1)

g med1= (inlist(industry1, ///
92, /// /*"Pastoral care and welfare" */
87, /// /*"Arts and crafts" */
82, /// /*"Security and organization" */
80, /// /*"Personal hygiene"*/
73, /// /*"Communication" */
70, /// /*"Traffic"*/
69, /// /*"Services (without description)" */
67, /// /*"Trade" */
49, /// /*"Jewelry manufacture" */
48, /// /*"Clock making" */
41, /// /*"Mechanical engineering, metal production and processing" */
34 /// /*"Graphic arts" */
) & emp==1) 
 

 
g low1 = (inlist(industry1, ///
79, /// /*"Public hygiene"*/
78, /// /*"Cleaning"*/
75, /// /*"Hospitality and housekeeping" */
53, /// /*"Crafts (without description)" */
52, /// /*"Painting"*/
50, /// /*"Construction industry"*/
39, /// /*"Stone, earth and glass processing"*/
38, /// /*"Plastics production and processing"*/
37, /// /*"Chemical industry"*/
36, /// /*"Leather manufacture and leather processing"*/
35, /// /*"Printing works" */
33, /// /*"Paper making and paper processing"*/
32, /// /*"Cork processing"*/
30, /// /*"Woodworking"*/
27, /// /*"Textile processing"*/
25, /// /*"Textile manufacture and textile finishing" */
24, /// /*"Tobacco processing"*/
21, /// /*"Food production and processing"*/
20, /// /*"Mining, mineral production and processing"*/
14, /// /*"Forestry, fishing and hunting"*/
13, /// /*"Animal breeding and animal husbandry"*/
12, /// /*"Horticulture"*/
10 /// /*"Agriculture"*/
) & emp==1)

/*
93, "Other occupations"
-1, "Unknown"
-2  "Without specification"
94 "Workers (without a more detailed job description)"
*/
 

*********************************
** if missing info in industry **
*********************************

** replace with high-med-low based on the other employees at the same company 
** if others are mixed, don't replace

cap drop bur_scale* bur_num* bur_max*

forvalues i=1/2 {
g bur_scale`i'=1 if low`i'==1
replace bur_scale`i'=2 if med`i'==1
replace bur_scale`i'=3 if high`i'==1 
bys bur_id (bur_scale`i'): g bur_num`i'_=sum(bur_scale`i'!=bur_scale`i'[_n-1]) if !mi(bur_scale`i')
bys bur_id: egen bur_num`i'=max(bur_num`i'_)
bys bur_id: egen bur_max`i'=max(bur_scale`i')
replace low`i'=1 if bur_max`i'==1 & bur_num`i'==1 
replace med`i'=1 if bur_max`i'==2 & bur_num`i'==1 
replace high`i'=1 if bur_max`i'==3 & bur_num`i'==1 
}

cap drop bur_scale* bur_num* bur_max* 

foreach x in low med high {
forvalues i=1/2 {
replace `x'`i'=0 if emp==0 // obs before year 2000 can have industry code but emp==0
}
}

la val industry1 taet_typ_cd
la val industry2 bra_typ_cd

